import {
  Body,
  ClassSerializerInterceptor,
  Controller,
  Post,
  UseInterceptors,
} from '@nestjs/common';
import { AuthService } from './auth.service';
import { SigninUserDto } from './dto/signin-user.dto';
import { SerializeInterceptor } from '@/common/interceptors/serialize.interceptor';
import { PublicUserDto } from './dto/public-user.dto';
import { Serialize } from '@/common/decorators/serialize.decorator';

@Controller('auth')
// @UseInterceptors(SerializeInterceptor)
export class AuthController {
  constructor(private authService: AuthService) {}
  @Post('/signin')
  signin(@Body() dto: SigninUserDto) {
    const { username, password } = dto;
    return this.authService.signin(username, password);
  }
  @Post('/singup')
  // @UseInterceptors(ClassSerializerInterceptor)
  @Serialize(PublicUserDto)
  async signup(@Body() dto: SigninUserDto): Promise<PublicUserDto> {
    const { username, password } = dto;
    const user = await this.authService.signup(username, password);
    return user;
  }
}
